/** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
**/


function Terms() {
	this.container = get("terms_popup");
	this.acceptBtn = get("terms_accept_text");
	this.exitBtn = get("terms_exit_text");
	
	//insert translated text into terms container
	get("terms_title").text(str_terms_title);
	get("terms_accept_text").text(str_terms_accept);
	get("terms_exit_text").text(str_soft_menu_exit);
	get("terms_text").html(str_terms_text);
	
	var self = this;
	this.acceptBtn.click(function() { highlight($(this), function() { self.accept(); }); });
	this.exitBtn.click(exit);
}

Terms.prototype.accept = function () {	
	widget.setPreferenceForKey("true", "termsAccepted");
	this.hide();
}

Terms.prototype.isAccepted = function () {
	if (!phone) return true;
	return widget.preferenceForKey("termsAccepted");
}

Terms.prototype.show = function (onHide) {
	get("video_container").addClass("hidden");
	this.container.removeClass("hidden");
	this.onHide = onHide;
	
	// removing pressed state when coming from miniview
	setTimeout( function() {
		$("#terms_btn").removeClass("pressed");
	}, 100);
}

Terms.prototype.hide = function () {
	this.container.addClass("hidden");
	if(this.onHide) this.onHide();
}

